<?php
/**
 * The following variables are available in this template:
 * - $this: the CrudCode object
 */
?>
<?php echo "<?php\n"; ?>
/* @var $this <?php echo $this->getControllerClass(); ?> */
/* @var $model <?php echo $this->getModelClass(); ?> */
/* @var $form CActiveForm */
?>
<?php 
$label=$this->pluralize($this->class2name($this->modelClass));
echo "<?php"; ?> $this->beginWidget('ext.widgets.XPanel', array('title' => '<?php echo $label; ?>', 'width' => 900,'height' => 500)); 
?>
<div class="form">

<?php echo "<?php \$form=\$this->beginWidget('ext.CAxActiveForm', array(
	'id'=>'".$this->class2id($this->modelClass)."-form',
	'enableAjaxValidation'=>false,
)); ?>\n"; ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo "<?php echo \$form->errorSummary(\$model); ?>\n"; ?>
    <table class="ma-table">
        <tbody>
<?php
foreach($this->tableSchema->columns as $column)
{
	if($column->autoIncrement)
            continue;
        if($column->name == 'created_date' || $column->name == 'created_by' || $column->name == 'modified_date' || $column->name == 'modified_by')
            continue;
        $fieldType = 'textfield';
        if(isset($_POST['fields'][$column->name]))
             $fieldType = $_POST['fields'][$column->name];
        $addParam = '';
        if(isset($_POST['addparam-'.$column->name]))
                $addParam = $_POST['addparam-'.$column->name];
        
?>
	<tr>
		<td class="labelfield" style="width:200px"><?php echo "<?php echo ".$this->generateActiveLabel($this->modelClass,$column)."; ?>\n"; ?></td>
		<td><?php echo "<?php echo ".$this->generateActiveField($this->modelClass,$column,$fieldType,$addParam)."; ?>\n"; ?></td>
		<td><?php echo "<?php echo \$form->error(\$model,'{$column->name}'); ?>\n"; ?></td>
	</tr>

<?php
}
?>
	<tr>
		<td></td>
                <td><?php echo "<?php echo CHtml::submitButton(\$model->isNewRecord ? 'Create' : 'Save', array('class'=>'ax-btn')); ?>\n"; ?></td>
                <td></td>
	</tr>
        </tbody>
    </table>
<?php echo "<?php \$this->endWidget(); ?>\n"; ?>

</div><!-- form -->
<?php echo "<?php \$this->endWidget(); ?>"; ?>